package com.daxiong.hfs;

import org.apache.commons.collections4.CollectionUtils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.daxiong.hfs.bean.MainBean;
import com.daxiong.hfs.constant.Constant;
import com.daxiong.hfs.util.CommonUtil;

public class IntermediaryActivity extends Activity {

	private MainBean mainBean;

	private void initialize() {
		mainBean = CommonUtil.getMainBeanFormIntent(getIntent());
	}

	@Override
	public void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		initialize();

		setupViews();
	}

	private void setupViews() {
		Class<?> clazz = null;

		if (CollectionUtils.isEmpty(mainBean.getCompanyResultList())) {
			clazz = ProductDetailActivity.class;
		} else {
			clazz = CompanyResultActivity.class;
		}

		final Context context = IntermediaryActivity.this;

		final Intent intent = new Intent(context, clazz);

		final Bundle bundle = new Bundle();

		bundle.putSerializable(Constant.MAIN_BEAN_KEY, mainBean);

		intent.putExtras(bundle);

		startActivity(intent);
	}
}
